<%@page language="java" contentType="text/html; charset=utf-8"%>
<%@include file="/tagDeclare.jsp"%>
<%@include file="/headDeclare.jsp"%>
<%
	response.setHeader("cache-control", "public");
%>
<html>
<head>
<title>图片列表</title>
<style type="text/css">
fieldset,table,tr,td {
	margin: 0;
	padding: 0;
}

th {
	text-align: center;
}

td {
	text-align: left;
	width: auto;
}

form label {
	font-weight: bolder;
}

table {
	border-collapse: separate;
	border: 1px;
}

img,a {
	border: 0;
}

select {
	width: 80px;
}

</style>

<script type="text/javascript">
	$(document).ready(function() { 
		
		$().piroBox({my_speed: 200,bg_alpha: 0.1,slideShow : true,slideSpeed : 4,close_all : '.piro_close,.piro_overlay'});
	

			$("#imageTable").tablesorter({theme:'green', widgets:['zebra'],
	       		headers:{0:{sorter:false},
	       			1:{sorter:false},
	       			2:{sorter:false},
	       			3:{sorter:false},
	       			4:{sorter:false},
	       			5:{sorter:false},
	       			6:{sorter:false},
	       			7:{sorter:false}}
	       	});
		
		$("img").lazyload({
		     placeholder : "images/loading.gif", //加载图片前的占位图片
		     effect      : "fadeIn" //加载图片使用的效果(淡入)
		});
       	
       	
       	$("#btn_pageUp").click(function(){
			var curPage = $("#curPage").val();
			$("#curPage").val(parseInt(curPage) - 1);
			$("#imageForm").submit();
       	});
       	
       	$("#btn_pageDown").click(function(){
       		var curPage = $("#curPage").val();
			$("#curPage").val(parseInt(curPage) + 1);
			$("#imageForm").submit();
       	});

        $("#btn_insert").click(function(){
            var queryString = $("#imageForm").formSerialize();
            queryString = encodeURIComponent(queryString);
            location.href = "<%=basePath%>wall/insert.do?qs=" + queryString;
        });
        
        $("#btn_search").click(function(){
            $("#curPage").val(1);
            $("#imageForm").submit();
        });
        
        //批量删除
        $("#btn_batch_del").click(function(){
        	var ids = null;
        	$("input[name='checkName']:checkbox:checked").each(function(){ 
        		if(ids == null)
        			ids = $(this).val();
        		else
        		    ids +=","+$(this).val() ;
        	}) ;
        	if(ids==null || ids == "")
        		{
        			alert("请选择");
        			return;
        		}
        	location.href = "<%=basePath%>wall/batchDelete.do?ids=" + ids;
        });
        
        //批量导出
        $("#btn_export").click(function(){
        	var ids = "";
        	$("input[name='checkName']:checkbox:checked").each(function(){ 
        		if(ids == "")
        			ids = $(this).val();
        		else
        		    ids +=","+$(this).val() ;
        	}) ;
        	if(ids != ""){
       			$("#ids").val(ids);
       		}
        	$("#imageForm").attr("action","wall/batchExport.do");
        	$("#imageForm").submit();
        	$("#imageForm").attr("action","wall/list.do");
        	$("#ids").val("");
        });
        
        $("#btn_import").click(function(){
        	var filePath = $("#filePath").val();
        	var num = Math.random();
        	$.post("<%=basePath%>wall/import.do", { path: filePath,num:num},function(data){
       			   //由JSON字符串转换为JSON对象
       			   var responseJson = eval('(' + data + ')');
       			   if(responseJson.code==0)
       			   {
       					$('#error_label').text("错误信息：" + responseJson.message);
   		         		$("#p_error").show();
   		         		return;
       			   }else{
       					location.href = "<%=basePath%>wall/list.do";
					}
					});
				});

				$("#btn_change").click(function() {
					var page = parseInt($("#selectPage").val());
					var curPage = parseInt($("#curPage").val());
					if (curPage == page)
						return;
					$("#curPage").val(parseInt(page));
					$("#imageForm").submit();
				});

			});

	function view(id){

	}
</script>
</head>

<body>
	<div style="width: 100%;">
		<div style="margin: auto;">
			<fieldset>
				<p></p>
				<legend>查询条件：</legend>
				<form id="imageForm" method="post" action="image/list.do">
					<input type="hidden" name="ids" id="ids" />
					<table>
						<tr>
							<td><label for="name">名称:&nbsp;</label></td>
							<td><input type="text" name="name" id="name" value="${name }" style="width: 120px;" /></td>
							<td><input type="submit" id="btn_search" name="btn_search"
								value="查询" /></td>
						</tr>
					</table>
					<input type="hidden" name="curPage" id="curPage" value="${curPage}" />
					<input type="hidden" name="totalPage" id="totalPage"
						value="${totalPage}" />
				</form>
			</fieldset>
		</div>
		<hr />
		<div>
			<table id="imageTable" class="tablesorter">
				<thead>
					<tr>
						<th align="center"><span style="cursor: pointer"
							onclick="changeStatus('all')">全</span>/<span
							style="cursor: pointer" onclick="changeStatus('invert')">反</span>
						</th>
						<th style="white-space: nowrap;text-align: center;">序号</th>
						<th style="white-space: nowrap;text-align: center;">墙体地址</th>
						<th style="white-space: nowrap;text-align: center;">所属用户</th>
						<th style="white-space: nowrap;text-align: center;">联系方式</th>
						<th style="white-space: nowrap;text-align: center;">名称</th>
						<th style="white-space: nowrap;text-align: center;">操作</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${list}" var="image" varStatus="status">
						<tr>
							<td
								style="word-wrap: break-word; word-break: break-all; text-align: center;"><input
								name="checkName" type="checkbox" id="" value="${inage.id }" /></td>
							<td style="white-space: nowrap;text-align: center;">${status.index }</td>
							<td style="white-space: nowrap;text-align: center;">${image.province }${image.city }${image.county }${image.town }${image.address }</td>
							<td style="white-space: nowrap;text-align: center;">${image.username }</td>
							<td style="white-space: nowrap;text-align: center;">${image.tel }</td>
							<td style="white-space: nowrap;text-align: center;">${image.name }</td>
							<td style="white-space: nowrap;text-align: center;">
								<a href="${image.url }" target="_blank" >查看</a>
								<a href="${image.url }" target="_blank">删除</a>
							</td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
		</div>
		<hr />
		<div>
			<div style="float: left;">
				<c:if test="${username_attr.role == 1}">
					<input type="button" id="btn_batch_del" name="btn_batch_del"
						value="批量删除" style="width: 80px;" />
					<input type="button" id="btn_export" name="btn_excport"
						value="批量导出" style="width: 80px;" />
				</c:if>
			</div>
			<div style="text-align: right;">
				<c:if test="${curPage <= 1}">
					<input type="button" disabled="disabled" id="btn_pageUp"
						value="上一页" />
				</c:if>
				<c:if test="${curPage > 1}">
					<input type="button" id="btn_pageUp" value="上一页" />
				</c:if>
				<c:if test="${curPage >= totalPage}">
					<input type="button" id="btn_pageDown" disabled="disabled"
						value="下一页" />
				</c:if>
				<c:if test="${curPage < totalPage}">
					<input type="button" id="btn_pageDown" value="下一页" />
				</c:if>
				共${totalPage}页/共${totalRecords}条 <select id="selectPage"
					style="width: auto;">
					<c:forEach var="i" begin="1" end="${totalPage}">
						<option id="${i}"
							<c:if test="${i == curPage}">selected="selected"</c:if>>${i}</option>
					</c:forEach>
				</select>
				<c:if test="${totalPage == 0 }">
					<input id="btn_change" type="button" value="转至" disabled="disabled" />
				</c:if>
				<c:if test="${totalPage != 0 }">
					<input id="btn_change" type="button" value="转至" />
				</c:if>
			</div>
		</div>
	</div>
</body>
</html>

